package com.seagull.core.test.desing.guanchazhe;

import org.apache.catalina.LifecycleState;

import java.util.ArrayList;
import java.util.List;
import java.util.Observer;

/**
 * @author:jian.zhou
 * @date:2017/12/28
 * @version:0.0.1
 * @desc:主题
 */
public class Subject {


    /**
     * 用来保存注册观察者对象
     */
    private List<Observer> list = new ArrayList<>();


    public void add (Observer observer){
        list.add(observer);
    }

    public void delete ( Observer observer){
        list.remove(observer);
    }


    public void notify ( String  newState){
        for ( Observer observer : list ){
              observer.notify();
        }
    }
}
